/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package sys.screen;

import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.IOException;
import java.sql.SQLException;
import java.text.NumberFormat;
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.ImageIcon;
import javax.swing.InputMap;
import javax.swing.JTable;
import javax.swing.KeyStroke;
import javax.swing.SwingConstants;
import javax.swing.SwingWorker;
import javax.swing.UIManager;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.DefaultTableModel;
import sys.bean.ProdutoBean;
import sys.dao.ProdutoDao;
import sys.utils.LetterUpper;
import sys.utils.Mensagens;
import static sys.utils.Utils.escClose;

/**
 *
 * @author Cesar Daniel
 */
public class UIPesquisaProduto extends javax.swing.JDialog {

    NumberFormat formatoMoeda = NumberFormat.getCurrencyInstance();

    private CPedidosParaEntrega cPedidosEntrega;
    private CCadastroTracoProduto cCadastroProduto;

    int tela;

    public UIPesquisaProduto(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
        setLocationRelativeTo(null);
        setResizable(false);
        this.setIconImage(new ImageIcon(getClass().getResource("/sys/picture/icon.png")).getImage());
        UIManager.put("Table.alternateRowColor", new java.awt.Color(230, 255, 255));
        escClose(this);
        txDescProduto.requestFocus();
        cbConcreteira.setSelected(true);
    }

    public UIPesquisaProduto(CPedidosParaEntrega parent, boolean modal) {
        super(parent, modal);
        cPedidosEntrega = parent;
        initComponents();
        setLocationRelativeTo(null);
        setResizable(false);
        this.setIconImage(new ImageIcon(getClass().getResource("/sys/picture/icon.png")).getImage());
        UIManager.put("Table.alternateRowColor", new java.awt.Color(230, 255, 255));
        escClose(this);
        txDescProduto.requestFocus();
        tela = 1;
    }

    public UIPesquisaProduto(CCadastroTracoProduto parent, boolean modal) {
        super(parent, modal);
        cCadastroProduto = parent;
        initComponents();
        setLocationRelativeTo(null);
        setResizable(false);
        this.setIconImage(new ImageIcon(getClass().getResource("/sys/picture/icon.png")).getImage());
        UIManager.put("Table.alternateRowColor", new java.awt.Color(230, 255, 255));
        escClose(this);
        txDescProduto.requestFocus();
        tela = 2;
    }

    public String formatoMoeda(double valor) {
        return formatoMoeda.format(valor).replace("R$", "");
    }

    private String txConsulta() {
        if (jcbPesContenha.isSelected()) {
            String pParte = "";
            String uParte = "";
            String tx = txDescProduto.getText();

            String[] sql = tx.split(" ");

            int cont = 0;
            for (String conteudoTxproduto : sql) {
                if (cont == 0) {
                    pParte += "WHERE C01DESC LIKE '%" + conteudoTxproduto + "%' ";
                }
                if (cont > 0) {
                    uParte += "AND C01DESC LIKE '%" + conteudoTxproduto + "%' ";
                }
                cont++;
            }
            return pParte + uParte + " AND C01FLAG = 'A' ORDER BY C01DESC";
        } else {
            return "WHERE C01DESC LIKE '" + txDescProduto.getText() + "%' AND C01FLAG = 'A'";
        }
    }

    private void atualizaTabelaSPAC() {
        DefaultTableModel modelo = (DefaultTableModel) tabela.getModel();
        modelo.setNumRows(0);

        try {
            for (ProdutoBean produto : ProdutoDao.listaProdutosSpac(txConsulta())) {
                modelo.addRow(new Object[]{
                    produto.getCodigo(), produto.getDescricao(), produto.getUn(), formatoMoeda(produto.getpCusto()), formatoMoeda(produto.getpVenda())
                });
            }
        } catch (SQLException | IOException ex) {
            Mensagens.msgErro("erro\n" + ex.getMessage());
        }
        tabela.requestFocus();
        tabela.changeSelection(0, 5, false, false);

        DefaultTableCellRenderer centralizado = new DefaultTableCellRenderer();
        centralizado.setHorizontalAlignment(SwingConstants.CENTER);

        tabela.getColumnModel().getColumn(0).setCellRenderer(centralizado);
        tabela.getColumnModel().getColumn(2).setCellRenderer(centralizado);
        tabela.getColumnModel().getColumn(3).setCellRenderer(centralizado);
        tabela.getColumnModel().getColumn(4).setCellRenderer(centralizado);

    }

    private void atualizaTabelaMySQL() {
        DefaultTableModel modelo = (DefaultTableModel) tabela.getModel();
        modelo.setNumRows(0);

        try {
            for (ProdutoBean produto : ProdutoDao.listaProdutosMySQL(txDescProduto.getText())) {
                modelo.addRow(new Object[]{
                    produto.getCodigo(), produto.getDescricao(), produto.getUn(), formatoMoeda(produto.getpCusto()), formatoMoeda(produto.getpVenda())
                });
            }
        } catch (SQLException ex) {
            Mensagens.msgErro("erro\n" + ex.getMessage());
        }
        tabela.requestFocus();
        tabela.changeSelection(0, 5, false, false);

        DefaultTableCellRenderer centralizado = new DefaultTableCellRenderer();
        centralizado.setHorizontalAlignment(SwingConstants.CENTER);

        tabela.getColumnModel().getColumn(0).setCellRenderer(centralizado);
        tabela.getColumnModel().getColumn(2).setCellRenderer(centralizado);
        tabela.getColumnModel().getColumn(3).setCellRenderer(centralizado);
        tabela.getColumnModel().getColumn(4).setCellRenderer(centralizado);

    }

    private void selecionaProduto() {
        if (tela == 1) {
            this.cPedidosEntrega.txCodigoProduto.setText(tabela.getValueAt(tabela.getSelectedRow(), 0).toString());
            this.cPedidosEntrega.txDescProduto.setText(tabela.getValueAt(tabela.getSelectedRow(), 1).toString());
            this.dispose();
        }
        if (tela == 2) {
            this.cCadastroProduto.txCodigoProduto.setText(tabela.getValueAt(tabela.getSelectedRow(), 0).toString());
            this.cCadastroProduto.carregaProduto();
            this.cCadastroProduto.carregaTraco();
            this.dispose();
        }
    }

    private boolean validaInfo() {
        boolean v = true;
        String msg = "Selecione pelo menos uma opção de pesquisa.";

        if (cbDescricao.isSelected() || cbCodigoBarras.isSelected()) {
        } else {
            v = false;
        }
        if (jcbPesContenha.isSelected() || jcbPesIncremental.isSelected()) {
        } else {
            v = false;
        }
        if (v == false) {
            Mensagens.msgAtencao(msg);
        }
        return v;
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        tabela = new javax.swing.JTable();
        jPanel2 = new javax.swing.JPanel();
        txDescProduto = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        jPanel3 = new javax.swing.JPanel();
        jcbPesIncremental = new javax.swing.JCheckBox();
        jcbPesContenha = new javax.swing.JCheckBox();
        jPanel5 = new javax.swing.JPanel();
        cbDescricao = new javax.swing.JCheckBox();
        cbCodigoBarras = new javax.swing.JCheckBox();
        cbConcreteira = new javax.swing.JCheckBox();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("PESQUISAR CLIENTES");

        jPanel1.setBackground(new java.awt.Color(255, 255, 255));

        tabela.setAutoCreateRowSorter(true);
        tabela.setFont(new java.awt.Font("Calibri", 0, 12)); // NOI18N
        tabela.setForeground(new java.awt.Color(51, 51, 255));
        tabela.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "CODIGO", "PRODUTO", "UN", "P. CUSTO", "P. VENDA"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.Integer.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        tabela.setGridColor(new java.awt.Color(204, 204, 204));
        tabela.getTableHeader().setReorderingAllowed(false);
        jScrollPane1.setViewportView(tabela);
        if (tabela.getColumnModel().getColumnCount() > 0) {
            tabela.getColumnModel().getColumn(1).setPreferredWidth(300);
            tabela.getColumnModel().getColumn(2).setPreferredWidth(10);
        }
        InputMap im = tabela.getInputMap(JTable.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
        KeyStroke enter = KeyStroke.getKeyStroke("ENTER");

        im.put (enter, im.get
            (KeyStroke.getKeyStroke(KeyEvent.VK_GREATER, 0)));
        Action enterAction = new AbstractAction() {
            public void actionPerformed(ActionEvent e) {
                JTable tabela = (JTable) e.getSource();
                selecionaProduto();
            }

        };

        tabela.getActionMap ()

        .put(im.get(enter), enterAction);
        tabela.addMouseListener ( new MouseAdapter(){

            public void mouseClicked(MouseEvent e) {
                if (e.getClickCount() == 2) {
                    selecionaProduto();
                }
            }
        }
    );

    jPanel2.setBackground(new java.awt.Color(255, 255, 255));
    jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "OPÇÕES:", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Calibri", 0, 10))); // NOI18N

    txDescProduto.setDocument(new LetterUpper());
    txDescProduto.setBackground(new java.awt.Color(245, 245, 245));
    txDescProduto.setFont(new java.awt.Font("Calibri", 0, 14)); // NOI18N
    txDescProduto.setForeground(new java.awt.Color(51, 51, 255));
    txDescProduto.setBorder(null);
    txDescProduto.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            txDescProdutoActionPerformed(evt);
        }
    });

    jLabel1.setFont(new java.awt.Font("Calibri", 0, 11)); // NOI18N
    jLabel1.setText("DESCRIÇÃO DO PRODUTO:");

    javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
    jPanel2.setLayout(jPanel2Layout);
    jPanel2Layout.setHorizontalGroup(
        jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(jPanel2Layout.createSequentialGroup()
            .addContainerGap()
            .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(txDescProduto, javax.swing.GroupLayout.PREFERRED_SIZE, 558, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(jLabel1))
            .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
    );
    jPanel2Layout.setVerticalGroup(
        jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(jPanel2Layout.createSequentialGroup()
            .addComponent(jLabel1)
            .addGap(5, 5, 5)
            .addComponent(txDescProduto, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
    );

    jPanel3.setBackground(new java.awt.Color(255, 255, 255));
    jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "PESQUISA", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Calibri", 0, 10))); // NOI18N

    jcbPesIncremental.setBackground(new java.awt.Color(255, 255, 255));
    jcbPesIncremental.setFont(new java.awt.Font("Calibri", 0, 11)); // NOI18N
    jcbPesIncremental.setText("INCREMENTAL");
    jcbPesIncremental.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jcbPesIncrementalActionPerformed(evt);
        }
    });

    jcbPesContenha.setBackground(new java.awt.Color(255, 255, 255));
    jcbPesContenha.setFont(new java.awt.Font("Calibri", 0, 11)); // NOI18N
    jcbPesContenha.setSelected(true);
    jcbPesContenha.setText("CONTENHA");
    jcbPesContenha.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jcbPesContenhaActionPerformed(evt);
        }
    });

    javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
    jPanel3.setLayout(jPanel3Layout);
    jPanel3Layout.setHorizontalGroup(
        jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
            .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jcbPesIncremental)
            .addContainerGap())
        .addGroup(jPanel3Layout.createSequentialGroup()
            .addContainerGap()
            .addComponent(jcbPesContenha)
            .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
    );
    jPanel3Layout.setVerticalGroup(
        jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
            .addContainerGap()
            .addComponent(jcbPesContenha, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jcbPesIncremental, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addContainerGap())
    );

    jPanel5.setBackground(new java.awt.Color(255, 255, 255));
    jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "PESQUISA", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Calibri", 0, 10))); // NOI18N

    cbDescricao.setBackground(new java.awt.Color(255, 255, 255));
    cbDescricao.setFont(new java.awt.Font("Calibri", 0, 11)); // NOI18N
    cbDescricao.setSelected(true);
    cbDescricao.setText("DESCRIÇÃO");
    cbDescricao.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            cbDescricaoActionPerformed(evt);
        }
    });

    cbCodigoBarras.setBackground(new java.awt.Color(255, 255, 255));
    cbCodigoBarras.setFont(new java.awt.Font("Calibri", 0, 11)); // NOI18N
    cbCodigoBarras.setText("COD. BARRAS");
    cbCodigoBarras.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            cbCodigoBarrasActionPerformed(evt);
        }
    });

    cbConcreteira.setBackground(new java.awt.Color(255, 255, 255));
    cbConcreteira.setFont(new java.awt.Font("Calibri", 0, 11)); // NOI18N
    cbConcreteira.setText("PRODUTOS CONCRETEIRA");

    javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
    jPanel5.setLayout(jPanel5Layout);
    jPanel5Layout.setHorizontalGroup(
        jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(jPanel5Layout.createSequentialGroup()
            .addContainerGap()
            .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(cbConcreteira, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel5Layout.createSequentialGroup()
                    .addComponent(cbDescricao)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addComponent(cbCodigoBarras)
                    .addGap(0, 2, Short.MAX_VALUE)))
            .addContainerGap())
    );
    jPanel5Layout.setVerticalGroup(
        jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup()
            .addContainerGap()
            .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(cbDescricao, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(cbCodigoBarras, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(cbConcreteira, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE)
            .addContainerGap())
    );

    javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
    jPanel1.setLayout(jPanel1Layout);
    jPanel1Layout.setHorizontalGroup(
        jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(jPanel1Layout.createSequentialGroup()
            .addContainerGap()
            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                    .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(28, 28, 28))
                .addGroup(jPanel1Layout.createSequentialGroup()
                    .addComponent(jScrollPane1)
                    .addGap(29, 29, 29))))
    );
    jPanel1Layout.setVerticalGroup(
        jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
            .addGap(11, 11, 11)
            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                .addComponent(jPanel5, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jPanel2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 341, Short.MAX_VALUE)
            .addContainerGap())
    );

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(layout.createSequentialGroup()
            .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 929, Short.MAX_VALUE)
            .addGap(0, 0, 0))
    );
    layout.setVerticalGroup(
        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
    );

    pack();
    }// </editor-fold>//GEN-END:initComponents

    private void buscaProdutoSPAC() {
        final BarraProgresso pb = new BarraProgresso(this);
        SwingWorker worker = new SwingWorker() {

            @Override
            protected Object doInBackground() throws Exception {
                pb.gerarJanela();
                pb.lbDescricao.setText("BUSCANDO, POR FAVOR AGUARDE...");
                atualizaTabelaSPAC();
                return null;
            }

            @Override
            protected void done() {
                pb.fechar();
            }
        };
        worker.execute();
    }

    private void buscaProdutoMysql() {
        final BarraProgresso pb = new BarraProgresso(this);
        SwingWorker worker = new SwingWorker() {

            @Override
            protected Object doInBackground() throws Exception {
                pb.gerarJanela();
                pb.lbDescricao.setText("BUSCANDO, POR FAVOR AGUARDE...");
                atualizaTabelaMySQL();
                return null;
            }

            @Override
            protected void done() {
                pb.fechar();
            }
        };
        worker.execute();

    }
    private void jcbPesIncrementalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcbPesIncrementalActionPerformed
        jcbPesContenha.setSelected(false);
        txDescProduto.requestFocus();
        txDescProduto.selectAll();
    }//GEN-LAST:event_jcbPesIncrementalActionPerformed

    private void jcbPesContenhaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcbPesContenhaActionPerformed
        jcbPesIncremental.setSelected(false);
        txDescProduto.requestFocus();
        txDescProduto.selectAll();
    }//GEN-LAST:event_jcbPesContenhaActionPerformed

    private void txDescProdutoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txDescProdutoActionPerformed
        if (cbConcreteira.isSelected()) {
            buscaProdutoMysql();
        } else {
            buscaProdutoSPAC();
        }
    }//GEN-LAST:event_txDescProdutoActionPerformed

    private void cbCodigoBarrasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbCodigoBarrasActionPerformed
        cbDescricao.setSelected(false);
        cbConcreteira.setSelected(false);
        txDescProduto.requestFocus();
        txDescProduto.selectAll();
    }//GEN-LAST:event_cbCodigoBarrasActionPerformed

    private void cbDescricaoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbDescricaoActionPerformed
        cbCodigoBarras.setSelected(false);
        cbConcreteira.setSelected(false);
        txDescProduto.requestFocus();
        txDescProduto.selectAll();
    }//GEN-LAST:event_cbDescricaoActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JCheckBox cbCodigoBarras;
    private javax.swing.JCheckBox cbConcreteira;
    private javax.swing.JCheckBox cbDescricao;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JCheckBox jcbPesContenha;
    private javax.swing.JCheckBox jcbPesIncremental;
    private javax.swing.JTable tabela;
    private javax.swing.JTextField txDescProduto;
    // End of variables declaration//GEN-END:variables
}
